#define __OLIVE_HEADER_INCLUDED__
# line 1 "mybrg.brg"
/*
   FILE: sample4.brg
  
   Copyright (c) 1997 Princeton University

   All rights reserved.

   This software is to be used for non-commercial purposes only,
   unless authorized permission to do otherwise is obtained.  
   For more information, contact spam@ee.princeton.edu
*/
#include "llvm/Value.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "map"

const char* getregname(int i);

enum {
	ADDI=309, ADDRLP=295, ASGNI=53,  CNSTINT=11, CALL=77,
	CNSTI=21, CVCI=85, I0I=661, INDIRC=67, STORE=28, COMP=441, ARGS=887, GEP=666, ARGALLOC=444
};

typedef struct tree {
	int op;
	struct tree *kids[2];
	 long val;
        int size;
	struct { struct burm_state *state; } x;
} *NODEPTR, *Tree;
#define GET_KIDS(p)	((p)->kids)
#define PANIC printf
#define STATE_LABEL(p) ((p)->x.state)
#define SET_STATE(p,s) (p)->x.state=(s)
#define DEFAULT_COST	break
#define NO_ACTION(x)



typedef struct COST {
    int cost;
} COST;
#define COST_LESS(a,b) ((a).cost < (b).cost)

static COST COST_INFINITY = { 32767 };
static COST COST_ZERO     = { 0 };


int OP_LABEL(NODEPTR p) {
	switch (p->op) {
	case CNSTI:  if (p->val == 0) return 661 /* I0I */;
	default:     return p->op;
	}
}

static FILE *f;
 int getmem(llvm::Value* );
int getreg(llvm::Value* );
int isalreadyinmemory(llvm::Value* );
int isalreadyinregister(llvm::Value* );
   int getnumelem(llvm::Value *);
int offset = 0;
char* global;

//static void burm_trace(NODEPTR, int, int, int);
#define BURP 0
#define STORE 1
#define CNSTINT 2
#define COMP 3
#define ARGS 4
#define GEP 5
#define LOAD 6
#define ALLOCA 7
#define ADD 8
#define MUL 9
#define SUB 10
#define DIV 11
#define ASR 12
#define SL 13
#define CALL 14
#define SDIV 15
#define GLOBAL 16
#define ARGALLOC 17
#define RETURN 18
#define SHR 19
#define CNSTI 20
#define OR 21
#define AND 22
#define XOR 23
#define UMUL 24

struct burm_state {
  int op;
  NODEPTR node;
  struct burm_state **kids;
  COST cost[8];
  struct {
    unsigned burm_stmt:4;
    unsigned burm_mem:1;
    unsigned burm_reg:6;
    unsigned burm_con:1;
    unsigned burm_memc:1;
    unsigned burm_gc:1;
    unsigned burm__:1;
  } rule;
};

#ifndef ALLOC
#define ALLOC(n) malloc(n)
#endif

#ifndef burm_assert
#define burm_assert(x,y) if (!(x)) {  y; abort(); }
#endif

#define burm_stmt_NT 1
#define burm_mem_NT 2
#define burm_reg_NT 3
#define burm_con_NT 4
#define burm_memc_NT 5
#define burm_gc_NT 6
#define burm___NT 7
extern int burm_max_nt;
int burm_max_nt = 7;

char *burm_ntname[] = {
  0,
  "stmt",
  "mem",
  "reg",
  "con",
  "memc",
  "gc",
  "_",
  0
};

static short burm_nts_0[] = { burm___NT, burm___NT, burm___NT, 0 };
static short burm_nts_1[] = { burm_reg_NT, 0 };
static short burm_nts_2[] = { burm_con_NT, 0 };
static short burm_nts_3[] = { burm_mem_NT, 0 };
static short burm_nts_4[] = { burm_reg_NT, burm_reg_NT, 0 };
static short burm_nts_5[] = { burm_reg_NT, burm_con_NT, 0 };
static short burm_nts_6[] = { burm_con_NT, burm_reg_NT, 0 };
static short burm_nts_7[] = { burm_con_NT, burm_con_NT, 0 };
static short burm_nts_8[] = { 0 };
static short burm_nts_9[] = { burm_memc_NT, burm_mem_NT, 0 };
static short burm_nts_10[] = { burm_mem_NT, burm_mem_NT, 0 };
static short burm_nts_11[] = { burm_reg_NT, burm_mem_NT, 0 };
static short burm_nts_12[] = { burm_con_NT, burm_mem_NT, 0 };
static short burm_nts_13[] = { burm_mem_NT, burm_reg_NT, 0 };
static short burm_nts_14[] = { burm_mem_NT, burm_con_NT, 0 };
static short burm_nts_15[] = { burm_gc_NT, 0 };

short *burm_nts[] = {
  burm_nts_0,  /* 0 */
  burm_nts_1,  /* 1 */
  burm_nts_2,  /* 2 */
  burm_nts_1,  /* 3 */
  burm_nts_3,  /* 4 */
  burm_nts_4,  /* 5 */
  burm_nts_5,  /* 6 */
  burm_nts_6,  /* 7 */
  burm_nts_7,  /* 8 */
  burm_nts_8,  /* 9 */
  burm_nts_9,  /* 10 */
  burm_nts_10,  /* 11 */
  burm_nts_11,  /* 12 */
  burm_nts_12,  /* 13 */
  burm_nts_6,  /* 14 */
  burm_nts_4,  /* 15 */
  burm_nts_8,  /* 16 */
  burm_nts_8,  /* 17 */
  burm_nts_8,  /* 18 */
  burm_nts_8,  /* 19 */
  burm_nts_4,  /* 20 */
  burm_nts_13,  /* 21 */
  burm_nts_5,  /* 22 */
  burm_nts_14,  /* 23 */
  burm_nts_4,  /* 24 */
  burm_nts_6,  /* 25 */
  burm_nts_5,  /* 26 */
  burm_nts_4,  /* 27 */
  burm_nts_6,  /* 28 */
  burm_nts_5,  /* 29 */
  burm_nts_4,  /* 30 */
  burm_nts_6,  /* 31 */
  burm_nts_5,  /* 32 */
  burm_nts_4,  /* 33 */
  burm_nts_6,  /* 34 */
  burm_nts_5,  /* 35 */
  burm_nts_4,  /* 36 */
  burm_nts_6,  /* 37 */
  burm_nts_5,  /* 38 */
  burm_nts_4,  /* 39 */
  burm_nts_6,  /* 40 */
  burm_nts_5,  /* 41 */
  burm_nts_4,  /* 42 */
  burm_nts_6,  /* 43 */
  burm_nts_5,  /* 44 */
  burm_nts_4,  /* 45 */
  burm_nts_6,  /* 46 */
  burm_nts_5,  /* 47 */
  burm_nts_4,  /* 48 */
  burm_nts_6,  /* 49 */
  burm_nts_5,  /* 50 */
  burm_nts_4,  /* 51 */
  burm_nts_6,  /* 52 */
  burm_nts_5,  /* 53 */
  burm_nts_4,  /* 54 */
  burm_nts_6,  /* 55 */
  burm_nts_5,  /* 56 */
  burm_nts_15,  /* 57 */
  burm_nts_3,  /* 58 */
  burm_nts_1,  /* 59 */
};

char burm_arity[] = {
  3,  /* 0=BURP */
  2,  /* 1=STORE */
  0,  /* 2=CNSTINT */
  2,  /* 3=COMP */
  1,  /* 4=ARGS */
  2,  /* 5=GEP */
  1,  /* 6=LOAD */
  0,  /* 7=ALLOCA */
  2,  /* 8=ADD */
  2,  /* 9=MUL */
  2,  /* 10=SUB */
  2,  /* 11=DIV */
  2,  /* 12=ASR */
  2,  /* 13=SL */
  0,  /* 14=CALL */
  2,  /* 15=SDIV */
  0,  /* 16=GLOBAL */
  0,  /* 17=ARGALLOC */
  1,  /* 18=RETURN */
  2,  /* 19=SHR */
  0,  /* 20=CNSTI */
  2,  /* 21=OR */
  2,  /* 22=AND */
  2,  /* 23=XOR */
  0,  /* 24=UMUL */
};

char *burm_opname[] = {
  /* 0 */  "BURP",
  /* 1 */  "STORE",
  /* 2 */  "CNSTINT",
  /* 3 */  "COMP",
  /* 4 */  "ARGS",
  /* 5 */  "GEP",
  /* 6 */  "LOAD",
  /* 7 */  "ALLOCA",
  /* 8 */  "ADD",
  /* 9 */  "MUL",
  /* 10 */  "SUB",
  /* 11 */  "DIV",
  /* 12 */  "ASR",
  /* 13 */  "SL",
  /* 14 */  "CALL",
  /* 15 */  "SDIV",
  /* 16 */  "GLOBAL",
  /* 17 */  "ARGALLOC",
  /* 18 */  "RETURN",
  /* 19 */  "SHR",
  /* 20 */  "CNSTI",
  /* 21 */  "OR",
  /* 22 */  "AND",
  /* 23 */  "XOR",
  /* 24 */  "UMUL",
};


char *burm_string[] = {
  /* 0 */  "stmt: BURP(_,_,_)",
  /* 1 */  "stmt: RETURN(reg)",
  /* 2 */  "stmt: RETURN(con)",
  /* 3 */  "stmt: ARGS(reg)",
  /* 4 */  "stmt: ARGS(mem)",
  /* 5 */  "stmt: COMP(reg,reg)",
  /* 6 */  "stmt: COMP(reg,con)",
  /* 7 */  "stmt: COMP(con,reg)",
  /* 8 */  "stmt: COMP(con,con)",
  /* 9 */  "memc: ARGALLOC",
  /* 10 */  "stmt: STORE(memc,mem)",
  /* 11 */  "stmt: STORE(mem,mem)",
  /* 12 */  "stmt: STORE(reg,mem)",
  /* 13 */  "stmt: STORE(con,mem)",
  /* 14 */  "stmt: STORE(con,reg)",
  /* 15 */  "stmt: STORE(reg,reg)",
  /* 16 */  "con: CNSTINT",
  /* 17 */  "gc: GLOBAL",
  /* 18 */  "mem: ALLOCA",
  /* 19 */  "reg: CALL",
  /* 20 */  "reg: GEP(reg,reg)",
  /* 21 */  "reg: GEP(mem,reg)",
  /* 22 */  "reg: GEP(reg,con)",
  /* 23 */  "reg: GEP(mem,con)",
  /* 24 */  "reg: ADD(reg,reg)",
  /* 25 */  "reg: ADD(con,reg)",
  /* 26 */  "reg: ADD(reg,con)",
  /* 27 */  "reg: SUB(reg,reg)",
  /* 28 */  "reg: SUB(con,reg)",
  /* 29 */  "reg: SUB(reg,con)",
  /* 30 */  "reg: MUL(reg,reg)",
  /* 31 */  "reg: MUL(con,reg)",
  /* 32 */  "reg: MUL(reg,con)",
  /* 33 */  "reg: DIV(reg,reg)",
  /* 34 */  "reg: DIV(con,reg)",
  /* 35 */  "reg: DIV(reg,con)",
  /* 36 */  "reg: SDIV(reg,reg)",
  /* 37 */  "reg: SDIV(con,reg)",
  /* 38 */  "reg: SDIV(reg,con)",
  /* 39 */  "reg: ASR(reg,reg)",
  /* 40 */  "reg: ASR(con,reg)",
  /* 41 */  "reg: ASR(reg,con)",
  /* 42 */  "reg: SHR(reg,reg)",
  /* 43 */  "reg: SHR(con,reg)",
  /* 44 */  "reg: SHR(reg,con)",
  /* 45 */  "reg: SL(reg,reg)",
  /* 46 */  "reg: SL(con,reg)",
  /* 47 */  "reg: SL(reg,con)",
  /* 48 */  "reg: AND(reg,reg)",
  /* 49 */  "reg: AND(con,reg)",
  /* 50 */  "reg: AND(reg,con)",
  /* 51 */  "reg: OR(reg,reg)",
  /* 52 */  "reg: OR(con,reg)",
  /* 53 */  "reg: OR(reg,con)",
  /* 54 */  "reg: XOR(reg,reg)",
  /* 55 */  "reg: XOR(con,reg)",
  /* 56 */  "reg: XOR(reg,con)",
  /* 57 */  "reg: LOAD(gc)",
  /* 58 */  "reg: LOAD(mem)",
  /* 59 */  "reg: LOAD(reg)",
};


char *burm_files[] = {
"mybrg.brg",
"mybrg.c",
};

int burm_file_numbers[] = {
  /* 0 */  0,
  /* 1 */  0,
  /* 2 */  0,
  /* 3 */  0,
  /* 4 */  0,
  /* 5 */  0,
  /* 6 */  0,
  /* 7 */  0,
  /* 8 */  0,
  /* 9 */  0,
  /* 10 */  0,
  /* 11 */  0,
  /* 12 */  0,
  /* 13 */  0,
  /* 14 */  0,
  /* 15 */  0,
  /* 16 */  0,
  /* 17 */  0,
  /* 18 */  0,
  /* 19 */  0,
  /* 20 */  0,
  /* 21 */  0,
  /* 22 */  0,
  /* 23 */  0,
  /* 24 */  0,
  /* 25 */  0,
  /* 26 */  0,
  /* 27 */  0,
  /* 28 */  0,
  /* 29 */  0,
  /* 30 */  0,
  /* 31 */  0,
  /* 32 */  0,
  /* 33 */  0,
  /* 34 */  0,
  /* 35 */  0,
  /* 36 */  0,
  /* 37 */  0,
  /* 38 */  0,
  /* 39 */  0,
  /* 40 */  0,
  /* 41 */  0,
  /* 42 */  0,
  /* 43 */  0,
  /* 44 */  0,
  /* 45 */  0,
  /* 46 */  0,
  /* 47 */  0,
  /* 48 */  0,
  /* 49 */  0,
  /* 50 */  0,
  /* 51 */  0,
  /* 52 */  0,
  /* 53 */  0,
  /* 54 */  0,
  /* 55 */  0,
  /* 56 */  0,
  /* 57 */  0,
  /* 58 */  0,
  /* 59 */  0,
};

int burm_line_numbers[] = {
  /* 0 */  89,
  /* 1 */  96,
  /* 2 */  108,
  /* 3 */  123,
  /* 4 */  133,
  /* 5 */  145,
  /* 6 */  156,
  /* 7 */  167,
  /* 8 */  182,
  /* 9 */  201,
  /* 10 */  221,
  /* 11 */  243,
  /* 12 */  272,
  /* 13 */  295,
  /* 14 */  305,
  /* 15 */  318,
  /* 16 */  338,
  /* 17 */  345,
  /* 18 */  353,
  /* 19 */  373,
  /* 20 */  399,
  /* 21 */  445,
  /* 22 */  487,
  /* 23 */  532,
  /* 24 */  575,
  /* 25 */  606,
  /* 26 */  637,
  /* 27 */  667,
  /* 28 */  698,
  /* 29 */  729,
  /* 30 */  760,
  /* 31 */  791,
  /* 32 */  822,
  /* 33 */  857,
  /* 34 */  893,
  /* 35 */  931,
  /* 36 */  969,
  /* 37 */  1005,
  /* 38 */  1043,
  /* 39 */  1081,
  /* 40 */  1115,
  /* 41 */  1149,
  /* 42 */  1179,
  /* 43 */  1213,
  /* 44 */  1247,
  /* 45 */  1279,
  /* 46 */  1313,
  /* 47 */  1347,
  /* 48 */  1374,
  /* 49 */  1405,
  /* 50 */  1436,
  /* 51 */  1465,
  /* 52 */  1496,
  /* 53 */  1527,
  /* 54 */  1557,
  /* 55 */  1588,
  /* 56 */  1619,
  /* 57 */  1650,
  /* 58 */  1673,
  /* 59 */  1692,
};
static short burm_decode_stmt[] = {
   -1,
  0,
  1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  10,
  11,
  12,
  13,
  14,
  15,
};

static short burm_decode_mem[] = {
   -1,
  18,
};

static short burm_decode_reg[] = {
   -1,
  19,
  20,
  21,
  22,
  23,
  24,
  25,
  26,
  27,
  28,
  29,
  30,
  31,
  32,
  33,
  34,
  35,
  36,
  37,
  38,
  39,
  40,
  41,
  42,
  43,
  44,
  45,
  46,
  47,
  48,
  49,
  50,
  51,
  52,
  53,
  54,
  55,
  56,
  57,
  58,
  59,
};

static short burm_decode_con[] = {
   -1,
  16,
};

static short burm_decode_memc[] = {
   -1,
  9,
};

static short burm_decode_gc[] = {
   -1,
  17,
};

static short burm_decode__[] = {
   -1,
};

int burm_rule(struct burm_state *state, int goalnt) {
  burm_assert(goalnt >= 1 && goalnt <= 7,
        PANIC("Bad goal nonterminal %d in burm_rule\n", goalnt));
  if (!state)
    return 0;
  switch (goalnt) {
  case burm_stmt_NT:  return burm_decode_stmt[((struct burm_state *)state)->rule.burm_stmt];
  case burm_mem_NT:  return burm_decode_mem[((struct burm_state *)state)->rule.burm_mem];
  case burm_reg_NT:  return burm_decode_reg[((struct burm_state *)state)->rule.burm_reg];
  case burm_con_NT:  return burm_decode_con[((struct burm_state *)state)->rule.burm_con];
  case burm_memc_NT:  return burm_decode_memc[((struct burm_state *)state)->rule.burm_memc];
  case burm_gc_NT:  return burm_decode_gc[((struct burm_state *)state)->rule.burm_gc];
  case burm___NT:  return burm_decode__[((struct burm_state *)state)->rule.burm__];
  default:
    burm_assert(0, PANIC("Bad goal nonterminal %d in burm_rule\n", goalnt));
  }
  return 0;
}


struct burm_action {
  int nt;
  struct burm_state* st;
};

#ifndef RULE
#define RULE(n,s) \
    (act = (burm_action*) malloc(sizeof(struct burm_action)),act->nt=n,act->st=s,act)
#endif

int burm_cost_code(COST *_c, int _ern,struct burm_state *_s)
{
  NODEPTR *_children;
  struct burm_action *act;
  switch(_ern){
  default:
    DEFAULT_COST;
  case 0:
    _children = GET_KIDS(_s->node);
{

# line 88 "mybrg.brg"
 return 1; 
}
  break;
  case 1:
{

# line 95 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[0]->cost[burm_reg_NT].cost+1;
}
  break;
  case 2:
{

# line 107 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[0]->cost[burm_con_NT].cost+1;
}
  break;
  case 3:
{

# line 122 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost;
}
  break;
  case 4:
{

# line 132 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_mem_NT].cost;
}
  break;
  case 5:
{

# line 144 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1;
}
  break;
  case 6:
{

# line 155 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1;
}
  break;
  case 7:
{

# line 166 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1;
}
  break;
  case 8:
{

# line 181 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1;
}
  break;
  case 9:
{

# line 200 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  case 10:
{

# line 220 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_memc_NT].cost+_s->kids[1]->cost[burm_mem_NT].cost+1;
}
  break;
  case 11:
{

# line 242 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_mem_NT].cost+_s->kids[1]->cost[burm_mem_NT].cost+1;
}
  break;
  case 12:
{

# line 271 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_mem_NT].cost+1;
}
  break;
  case 13:
{

# line 294 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_mem_NT].cost+1;
}
  break;
  case 14:
{

# line 304 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1;
}
  break;
  case 15:
{

# line 317 "mybrg.brg"
(*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1;
}
  break;
  case 16:
{

# line 337 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  case 17:
{

# line 344 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  case 18:
{

# line 352 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  case 19:
{

# line 372 "mybrg.brg"
(*_c).cost = 1;
}
  break;
  case 20:
{

# line 398 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 21:
{

# line 444 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_mem_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 22:
{

# line 486 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 23:
{

# line 531 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_mem_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 24:
{

# line 574 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 25:
{

# line 605 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 26:
{

# line 636 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 27:
{

# line 666 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 28:
{

# line 697 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 29:
{

# line 728 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 30:
{

# line 759 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 31:
{

# line 790 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 32:
{

# line 821 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 33:
{

# line 856 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 34:
{

# line 892 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 35:
{

# line 930 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 36:
{

# line 968 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 37:
{

# line 1004 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 38:
{

# line 1042 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 39:
{

# line 1080 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 40:
{

# line 1114 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 41:
{

# line 1148 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 42:
{

# line 1178 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 43:
{

# line 1212 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 44:
{

# line 1246 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 45:
{

# line 1278 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 46:
{

# line 1312 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 47:
{

# line 1346 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 48:
{

# line 1373 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 49:
{

# line 1404 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 50:
{

# line 1435 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 51:
{

# line 1464 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 52:
{

# line 1495 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 53:
{

# line 1526 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 54:
{

# line 1556 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 55:
{

# line 1587 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_con_NT].cost+_s->kids[1]->cost[burm_reg_NT].cost+1; 
}
  break;
  case 56:
{

# line 1618 "mybrg.brg"
 (*_c).cost=_s->kids[0]->cost[burm_reg_NT].cost+_s->kids[1]->cost[burm_con_NT].cost+1; 
}
  break;
  case 57:
{

# line 1649 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  case 58:
{

# line 1672 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  case 59:
{

# line 1691 "mybrg.brg"
(*_c).cost = 2;
}
  break;
  }
  return 1;
}

# line 73 "mybrg.brg"
void stmt_action(struct burm_state *_s, 
# line 73 "mybrg.brg"
int indent);

# line 74 "mybrg.brg"
int mem_action(struct burm_state *_s, 
# line 74 "mybrg.brg"
int indent);

# line 75 "mybrg.brg"
int reg_action(struct burm_state *_s, 
# line 75 "mybrg.brg"
int indent);

# line 76 "mybrg.brg"
void con_action(struct burm_state *_s, 
# line 76 "mybrg.brg"
int indent);

# line 77 "mybrg.brg"
int memc_action(struct burm_state *_s, 
# line 77 "mybrg.brg"
int indent);

# line 78 "mybrg.brg"
void gc_action(struct burm_state *_s, 
# line 78 "mybrg.brg"
int indent);


#include <stdarg.h>

void burm_exec(struct burm_state *state, int nterm, ...) 
{
  va_list(ap);
  va_start(ap,nterm);

  burm_assert(nterm >= 1 && nterm <= 7,
        PANIC("Bad nonterminal %d in $exec\n", nterm));

  if (state)
    switch (nterm) {
    case burm_stmt_NT:
      stmt_action(state,va_arg(ap,int));
      break;
    case burm_mem_NT:
      PANIC("$exec cannot take non-void functions as arguments\n");
      break;
    case burm_reg_NT:
      PANIC("$exec cannot take non-void functions as arguments\n");
      break;
    case burm_con_NT:
      con_action(state,va_arg(ap,int));
      break;
    case burm_memc_NT:
      PANIC("$exec cannot take non-void functions as arguments\n");
      break;
    case burm_gc_NT:
      gc_action(state,va_arg(ap,int));
      break;
    default:
      PANIC("Bad nonterminal %d in $exec\n", nterm);
      break;
    }
  else
    PANIC("Bad state for $exec in nonterminal %d \n",nterm);
  va_end(ap);
}

#define EXEC(s,n,a) ( \
  (n == burm_stmt_NT)? burm_exec(s,n,a): \
  (n == burm_con_NT)? burm_exec(s,n,a): \
  (n == burm_gc_NT)? burm_exec(s,n,a): \
  PANIC("Bad nonterminal %d in $exec\n", n))

struct burm_state *burm_immed(struct burm_state *s,int n);
#ifndef NO_ACTION
#define NO_ACTION assert(0)
#endif

# line 73 "mybrg.brg"
void stmt_action(struct burm_state *_s, 
# line 73 "mybrg.brg"
int indent)
{
  struct burm_state *_t;
  int _ern=burm_decode_stmt[_s->rule.burm_stmt];
  NODEPTR *_children;
  if(_s->rule.burm_stmt==0)
    NO_ACTION(stmt);
  switch(_ern){
  case 0:
    _children = GET_KIDS(_s->node);
{

# line 89 "mybrg.brg"

		stmt_action(burm_immed(_s,0),10);
	
}
  break;
  case 1:
{

# line 96 "mybrg.brg"

    fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
int reg1;
    //fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
    reg1 = reg_action(_s->kids[0],indent+1);
   // reg_action(_s->kids[0],indent+1);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax") ;

}
  break;
  case 2:
{

# line 108 "mybrg.brg"

    fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
//int reg1;
    //fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
   // reg1 = con_action(_s->kids[0],indent+1);
   // con_action(_s->kids[0],indent+1);
    fprintf(f,"\tmovq\t$%d, %%%s\n",_s->kids[0]->node->val,"rax") ;

}
  break;
  case 3:
{

# line 123 "mybrg.brg"

    int reg1;
    //fprintf(stderr, "%s\n", burm_string[_ern]);
    reg1 = reg_action(_s->kids[0],indent+1);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");


}
  break;
  case 4:
{

# line 133 "mybrg.brg"

    //fprintf(stderr, "%s\n", burm_string[_ern]);
    int meml;
    meml = mem_action(_s->kids[0],indent+1);
    fprintf(f,"\tleaq\t-%d(%%rbp), %%%s\n",meml,"rax");


}
  break;
  case 5:
{

# line 145 "mybrg.brg"

    //fprintf(stderr, "%s\n", burm_string[_ern]);
    int reg1, reg2;
    reg1 = reg_action(_s->kids[0],indent+1);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = reg_action(_s->kids[1],indent+1);
    fprintf(f,"\tcmpq\t%%%s, %%%s\n",getregname(reg2),"rax");
    

}
  break;
  case 6:
{

# line 156 "mybrg.brg"

    //fprintf(stderr, "%s\n", burm_string[_ern]);
    int reg1;
   // reg1 = reg_action(_s->kids[0],indent+1);
    //fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg1 = reg_action(_s->kids[0],indent+1);
    fprintf(f,"\tcmpq\t$%ld, %%%s\n",_s->kids[1]->node->val,getregname(reg1));


}
  break;
  case 7:
{

# line 167 "mybrg.brg"

   // fprintf(stderr, "%s\n", burm_string[_ern]);
    int reg1;
    reg1 = reg_action(_s->kids[1],indent+1);
    //fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    //reg2 = reg_action(_s->kids[1],indent+1);

    fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
    fprintf(f,"\tcmpq\t%%%s, %%%s\n",getregname(reg1),"rax");


}
  break;
  case 8:
{

# line 182 "mybrg.brg"

   // fprintf(stderr, "%s\n", burm_string[_ern]);

    //fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    //reg2 = con_action(_s->kids[1],indent+1);

    fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
    fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rbx");
    fprintf(f,"\tcmpq\t%%%s, %%%s\n","rax","rbx");


}
  break;
  case 10:
{

# line 221 "mybrg.brg"

    int meml1,meml2;
    fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
    meml1 = memc_action(_s->kids[0],indent+1);

    meml2 = mem_action(_s->kids[1],indent+1);
        {
      //  fprintf(stderr,"%s","\n\tStore value already in register\n");
       // fprintf(f, "\tleaq\t-%d(%%rbp) ,%%%s\n",meml1,"rax");
        fprintf(f, "\tmovq\t-%d(%%rbp), %%%s\n",meml1,"rax");
        fprintf(f, "\tmovq\t%%%s, -%d(%%rbp)\n","rax",meml2);


    }



}
  break;
  case 11:
{

# line 243 "mybrg.brg"

    int meml1,meml2;
    fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
    meml1 = mem_action(_s->kids[0],indent+1);
    //fprintf(f,"%d\n\n",val);
    meml2 = mem_action(_s->kids[1],indent+1);
    //regis = isalreadyinregister((llvm::Value*)_s->kids[1]->node->val);
    //if(regis == -1)//Memory value is in register, so moving to register instead of storing to memory. (Delayed write)
      //  fprintf(f, "\tmovq\t%%%s ,-%d(%%rbp)\n",getregname(reg1),meml);
    //else
    {
      //  fprintf(stderr,"%s","\n\tStore value already in register\n");
        fprintf(f, "\tleaq\t-%d(%%rbp) ,%%%s\n",meml1,"rax");
        fprintf(f, "\tmovq\t%%%s, -%d(%%rbp)\n","rax",meml2);


    }



}
  break;
  case 12:
{

# line 272 "mybrg.brg"

    int reg1,meml, regis;
    fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
    reg1 = reg_action(_s->kids[0],indent+1);
    //fprintf(f,"%d\n\n",val);
    meml = mem_action(_s->kids[1],indent+1);
    regis = isalreadyinregister((llvm::Value*)_s->kids[1]->node->val);
    if(regis == -1)//Memory value is in register, so moving to register instead of storing to memory. (Delayed write)
        fprintf(f, "\tmovq\t%%%s ,-%d(%%rbp)\n",getregname(reg1),meml);
    else
    {
      //  fprintf(stderr,"%s","\n\tStore value already in register\n");
        fprintf(f, "\tmovq\t%%%s ,%%%s\n",getregname(reg1),getregname(regis));

    }



}
  break;
  case 13:
{

# line 295 "mybrg.brg"

    fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
int meml;
   // con_action(_s->kids[0],indent+1);
   meml = mem_action(_s->kids[1],indent+1);
    fprintf(f,"\tmovq\t$%ld, -%d(%%rbp)\n",_s->kids[0]->node->val,meml) ;

}
  break;
  case 14:
{

# line 305 "mybrg.brg"

    fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
int reg1;
    //fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
    reg1 = reg_action(_s->kids[1],indent+1);
   // con_action(_s->kids[0],indent+1);
    fprintf(f,"\tmovq\t$%ld, (%%%s)\n",_s->kids[0]->node->val,getregname(reg1)) ;

}
  break;
  case 15:
{

# line 318 "mybrg.brg"

    fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
    int reg1, reg2;
    //fprintf(stderr, "%s\n", burm_string[_ern]);
    //fprintf(f,"%d\n",_s->node->op);
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f, "\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
  reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\tmovq\t%%%s, (%%%s)\n","rax",getregname(reg2)) ;

}
  break;
  }
}

# line 74 "mybrg.brg"
int mem_action(struct burm_state *_s, 
# line 74 "mybrg.brg"
int indent)
{
  struct burm_state *_t;
  int _ern=burm_decode_mem[_s->rule.burm_mem];
  NODEPTR *_children;
  if(_s->rule.burm_mem==0)
    NO_ACTION(mem);
  switch(_ern){
  case 18:
{

# line 353 "mybrg.brg"

    int regis, meml;
   fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
    regis = isalreadyinregister((llvm::Value*)_s->node->val);
    meml = getmem((llvm::Value*) (_s->node->val));
    if(regis != -1)//Updating memory from register
    {

        //fprintf(stderr,"\n\t%s\n","loaded memory in register");
        //fprintf(stderr,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(regis),meml);
        fprintf(f,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(regis),meml);
    }
    //fprintf(stderr, "Alloca %d\t""%s\n",meml, (const char*)burm_string[_ern]);
    return meml;
  
}
  break;
  }
}

# line 75 "mybrg.brg"
int reg_action(struct burm_state *_s, 
# line 75 "mybrg.brg"
int indent)
{
  struct burm_state *_t;
  int _ern=burm_decode_reg[_s->rule.burm_reg];
  NODEPTR *_children;
  if(_s->rule.burm_reg==0)
    NO_ACTION(reg);
  switch(_ern){
  case 19:
{

# line 373 "mybrg.brg"

    int regs, meml;
    regs = isalreadyinregister((llvm::Value*)_s->node->val);
    if(regs !=-1)
    {
        return regs;
    }
    meml =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(meml != -1)
    {
        //Moving the memory value to reg
          regs = getreg((llvm::Value*)_s->node->val);
          //fprintf(stderr,"\n\tloading the computed value from memory\n");
          fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",meml,getregname(regs));
          return regs;
    }
    
    {
        fprintf(stderr,"Call error in olive\n");
        exit(0);
    }
    return regs;

}
  break;
  case 20:
{

# line 399 "mybrg.brg"


    int reg1, reg2, regs, meml, size;

    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }

    meml =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(meml != -1)
    {
        //Moving the memory value to reg
          regs = getreg((llvm::Value*)_s->node->val);
          //fprintf(stderr,"\n\tloading the computed value from memory\n");
          fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",meml,getregname(regs));
          return regs;
    }
    reg1 = reg_action(_s->kids[0],indent);
    reg2 = reg_action(_s->kids[1],indent);
  
    size = getnumelem((llvm::Value*)_s->node->val);
    fprintf(f, "\tmovq\t$%d, %%%s\n",size, "rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f, "\timulq\t%%%s, %%%s\n",getregname(reg2),"rax");
    fprintf(f, "\timulq\t$%d, %%%s\n",-1,"rax");
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);

    fprintf(f,"\taddq\t%%%s, %%%s\n",getregname(reg1),"rax");

    

    regs = getreg((llvm::Value*)_s->node->val);

    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));


    return regs;




}
  break;
  case 21:
{

# line 445 "mybrg.brg"


    int reg1, meml, regs, size;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }

    meml =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(meml != -1)
    {
        //Moving the memory value to reg
          regs = getreg((llvm::Value*)_s->node->val);
          //fprintf(stderr,"\n\tloading the computed value from memory\n");
          fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",meml,getregname(regs));
          return regs;
    }
    meml = mem_action(_s->kids[0],indent);
    reg1 = reg_action(_s->kids[1],indent);
    size = getnumelem((llvm::Value*)_s->node->val);
        fprintf(f, "\tmovq\t$%d, %%%s\n",size, "rax");

 reg1 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f, "\timulq\t%%%s, %%%s\n",getregname(reg1),"rax");
fprintf(f, "\timulq\t$%d, %%%s\n",-1,"rax");
    fprintf(f, "\tleaq\t-%d(%%rbp) ,%%%s\n",meml,"rbx");
   // fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    //fprintf(f,"\tsalq\t$%d, %%%s\n",4,"rbx");
    fprintf(f, "\taddq\t%%%s, %%%s\n","rbx","rax");

 
    regs = getreg((llvm::Value*)_s->node->val);

    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));


    return regs;

}
  break;
  case 22:
{

# line 487 "mybrg.brg"


    int reg1, regs, meml, size;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }

    meml =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(meml != -1)
    {
        //Moving the memory value to reg
          regs = getreg((llvm::Value*)_s->node->val);
          //fprintf(stderr,"\n\tloading the computed value from memory\n");
          fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",meml,getregname(regs));
          return regs;
    }
    reg1 = reg_action(_s->kids[0],indent);

    size = getnumelem((llvm::Value*)_s->node->val);

    fprintf(stderr,"\n\tcon size = %d\n$3->val = %ld\n",size,_s->kids[1]->node->val);
    fprintf(f, "\tmovq\t$%d, %%%s\n",size, "rax");

    fprintf(f, "\timulq\t$%ld, %%%s\n",-_s->kids[1]->node->val,"rax");
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);

    fprintf(f,"\taddq\t%%%s, %%%s\n",getregname(reg1),"rax");




    regs = getreg((llvm::Value*)_s->node->val);

    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

    return regs;




}
  break;
  case 23:
{

# line 532 "mybrg.brg"


    int meml,regs,size;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }

    meml =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(meml != -1)
    {
        //Moving the memory value to reg
          regs = getreg((llvm::Value*)_s->node->val);
          //fprintf(stderr,"\n\tloading the computed value from memory\n");
          fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",meml,getregname(regs));
          return regs;
    }

    meml = mem_action(_s->kids[0],indent);

  size = getnumelem((llvm::Value*)_s->node->val);


    fprintf(f, "\tmovq\t$%d, %%%s\n",size, "rax");

     fprintf(f, "\timulq\t$%ld, %%%s\n",-_s->kids[1]->node->val,"rax");
    fprintf(f, "\tleaq\t-%d(%%rbp) ,%%%s\n",meml,"rbx");

    fprintf(f, "\taddq\t%%%s, %%%s\n","rbx","rax");


    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    return regs;


}
  break;
  case 24:
{

# line 575 "mybrg.brg"

    int  regs, reg1, reg2, memr;		
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }            
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\taddq\t%%%s, %%%s\n",getregname(reg2),"rax");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;
  

}
  break;
  case 25:
{

# line 606 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }
            
        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\taddq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;
     

  
}
  break;
  case 26:
{

# line 637 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }
           
        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\taddq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;  

}
  break;
  case 27:
{

# line 667 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\tsubq\t%%%s, %%%s\n",getregname(reg2),"rax");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 28:
{

# line 698 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }
        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        fprintf(f,"\tsubq\t%%%s, %%%s\n",getregname(reg1),"rax");

        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

  
}
  break;
  case 29:
{

# line 729 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }
        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\tsubq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


}
  break;
  case 30:
{

# line 760 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\timulq\t%%%s, %%%s\n",getregname(reg2),"rax");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 31:
{

# line 791 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }

        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\timulq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


  
}
  break;
  case 32:
{

# line 822 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }

        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\timulq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

}
  break;
  case 33:
{

# line 857 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");

    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    memr =  isalreadyinmemory((llvm::Value*) _s->kids[1]->node->val);

    fprintf(f,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(reg2),memr);
    fprintf(f,"\tcqto\n");
    fprintf(f,"\tdivq\t-%d(%%rbp)\n",memr);
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 34:
{

# line 893 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }

        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");



        memr =  isalreadyinmemory((llvm::Value*) _s->kids[1]->node->val);

        fprintf(f,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(reg1),memr);
        fprintf(f,"\tcqto\n");
        fprintf(f,"\tdivq\t-%d(%%rbp)\n",memr);
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


  
}
  break;
  case 35:
{

# line 931 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }

        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");

        // reg1 = getreg((llvm::Value*)_s->kids[1]->node->val);

        fprintf(f,"\tmovq\t$%ld, -%d(%%rbp)\n",_s->kids[1]->node->val,offset);
          fprintf(f,"\tcqto\n");

        fprintf(f,"\tdivq\t-%d(%%rbp)\n",offset);
        //fprintf(f,"\tidivq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

}
  break;
  case 36:
{

# line 969 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    memr =  isalreadyinmemory((llvm::Value*) _s->kids[1]->node->val);

    fprintf(f,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(reg2),memr);
    fprintf(f,"\tcqto\n");
    fprintf(f,"\tidivq\t-%d(%%rbp)\n",memr);
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 37:
{

# line 1005 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }

        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        


        memr =  isalreadyinmemory((llvm::Value*) _s->kids[1]->node->val);

        fprintf(f,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(reg1),memr);
        fprintf(f,"\tcqto\n");
        fprintf(f,"\tidivq\t-%d(%%rbp)\n",memr);
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


  
}
  break;
  case 38:
{

# line 1043 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }

        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");

        // reg1 = getreg((llvm::Value*)_s->kids[1]->node->val);

        fprintf(f,"\tmovq\t$%ld, -%d(%%rbp)\n",_s->kids[1]->node->val,offset);
          fprintf(f,"\tcqto\n");

        fprintf(f,"\tidivq\t-%d(%%rbp)\n",offset);
        //fprintf(f,"\tidivq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

}
  break;
  case 39:
{

# line 1081 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\tpushq\t%%%s\n","rcx");
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg2),"rcx");
    fprintf(f,"\tsarq\t%%%s, %%%s\n","cl","rax");
    fprintf(f,"\tpopq\t%%%s\n","rcx");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 40:
{

# line 1115 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }
        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        //fprintf(f,"\tsarq\t%%%s, %%%s\n",getregname(reg1),"rax");
         fprintf(f,"\tpushq\t%%%s\n","rcx");
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rcx");
        fprintf(f,"\tsarq\t%%%s, %%%s\n","cl","rax");
         fprintf(f,"\tpopq\t%%%s\n","rcx");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

  
}
  break;
  case 41:
{

# line 1149 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }
        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\tsarq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


}
  break;
  case 42:
{

# line 1179 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\tpushq\t%%%s\n","rcx");
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg2),"rcx");
    fprintf(f,"\tshrq\t%%%s, %%%s\n","cl","rax");
    fprintf(f,"\tpopq\t%%%s\n","rcx");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 43:
{

# line 1213 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }
        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        //fprintf(f,"\tsarq\t%%%s, %%%s\n",getregname(reg1),"rax");
         fprintf(f,"\tpushq\t%%%s\n","rcx");
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rcx");
        fprintf(f,"\tshrq\t%%%s, %%%s\n","cl","rax");
         fprintf(f,"\tpopq\t%%%s\n","rcx");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

  
}
  break;
  case 44:
{

# line 1247 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }
        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\tshrq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


}
  break;
  case 45:
{

# line 1279 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\tpushq\t%%%s\n","rcx");
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg2),"rcx");
    fprintf(f,"\tsalq\t%%%s, %%%s\n","cl","rax");
    fprintf(f,"\tpopq\t%%%s\n","rcx");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 46:
{

# line 1313 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }
        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        //fprintf(f,"\tsarq\t%%%s, %%%s\n",getregname(reg1),"rax");
         fprintf(f,"\tpushq\t%%%s\n","rcx");
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rcx");
        fprintf(f,"\tsalq\t%%%s, %%%s\n","cl","rax");
         fprintf(f,"\tpopq\t%%%s\n","rcx");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

  
}
  break;
  case 47:
{

# line 1347 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }
        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\tsalq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


}
  break;
  case 48:
{

# line 1374 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\tandq\t%%%s, %%%s\n",getregname(reg2),"rax");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 49:
{

# line 1405 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }

        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\tandq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


  
}
  break;
  case 50:
{

# line 1436 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }

        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\tandq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

}
  break;
  case 51:
{

# line 1465 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\torq\t%%%s, %%%s\n",getregname(reg2),"rax");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 52:
{

# line 1496 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }

        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\torq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


  
}
  break;
  case 53:
{

# line 1527 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }

        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\torq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

}
  break;
  case 54:
{

# line 1557 "mybrg.brg"

    int  regs, reg1, reg2, memr;
    regs = isalreadyinregister((llvm::Value*) _s->node->val);
    if(regs != -1)
    {
        return regs;
    }
    memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
    if(memr != -1)
    {
         //Moving the memory value to reg
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(stderr,"\n\tloading the computed value from memory\n");
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
        return regs;
    }
    reg1 = reg_action(_s->kids[0],indent+1);
    reg2 = reg_action(_s->kids[1],indent+1);
    reg1 = getreg((llvm::Value*)_s->kids[0]->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
    reg2 = getreg((llvm::Value*)_s->kids[1]->node->val);
    fprintf(f,"\txorq\t%%%s, %%%s\n",getregname(reg2),"rax");
    regs = getreg((llvm::Value*)_s->node->val);
    fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
    //  fprintf(stderr,"\t\treg = %d\treg1 = %d\treg2 = %d\n",regs,reg1,reg2);
    return regs;


}
  break;
  case 55:
{

# line 1588 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }

        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
            // fprintf(stderr,"\n\tloading the computed value from memory\n");
             fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
             return regs;
        }

        reg1 = reg_action(_s->kids[1],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\txorq\t$%ld, %%%s\n",_s->kids[0]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));
        return regs;


  
}
  break;
  case 56:
{

# line 1619 "mybrg.brg"

	int  regs, reg1, memr;

        regs = isalreadyinregister((llvm::Value*) _s->node->val);
        if(regs != -1)
        {
            return regs;
        }
        memr =  isalreadyinmemory((llvm::Value*) _s->node->val);
        if(memr != -1)
        {
            //Moving the memory value to reg
            regs = getreg((llvm::Value*)_s->node->val);
           // fprintf(stderr,"\n\tloading the computed value from memory\n");
            fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",memr,getregname(regs));
            return regs;
        }

        reg1 = reg_action(_s->kids[0],indent+1);
        fprintf(f,"\tmovq\t%%%s, %%%s\n",getregname(reg1),"rax");
        fprintf(f,"\txorq\t$%ld, %%%s\n",_s->kids[1]->node->val,"rax");
        regs = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t%%%s, %%%s\n","rax",getregname(regs));

        return regs;

}
  break;
  case 57:
{

# line 1650 "mybrg.brg"

        int regist, ml;
        //fprintf(stderr, "%s\n", burm_string[_ern]);
        regist = isalreadyinregister((llvm::Value*)_s->node->val);
        if(regist != -1)
        {
            //fprintf(stderr,"%s","\n\t**Load is already in register\n");
            return regist;
        }
        gc_action(_s->kids[0],indent+1);
        regist = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t(%%%s), %%%s\n","rax",getregname(regist));
        return regist;


    
}
  break;
  case 58:
{

# line 1673 "mybrg.brg"

        int regist, ml;
        //fprintf(stderr, "%s\n", burm_string[_ern]);
        regist = isalreadyinregister((llvm::Value*)_s->node->val);
        if(regist != -1)
        {
            //fprintf(stderr,"%s","\n\t**Load is already in register\n");
            return regist;
        }
        ml = mem_action(_s->kids[0],indent+1);
        regist = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t-%d(%%rbp), %%%s\n",ml,getregname(regist));
        return regist;


    
}
  break;
  case 59:
{

# line 1692 "mybrg.brg"

        int regist, reg1;
        //fprintf(stderr, "%s\n", burm_string[_ern]);
        regist = isalreadyinregister((llvm::Value*)_s->node->val);
        if(regist != -1)
        {
            //fprintf(stderr,"%s","\n\t**Load is already in register\n");
            return regist;
        }
        reg1 = reg_action(_s->kids[0],indent+1);
        regist = getreg((llvm::Value*)_s->node->val);
        fprintf(f,"\tmovq\t(%%%s), %%%s\n",getregname(reg1),getregname(regist));
        return regist;


    
}
  break;
  }
}

# line 76 "mybrg.brg"
void con_action(struct burm_state *_s, 
# line 76 "mybrg.brg"
int indent)
{
  struct burm_state *_t;
  int _ern=burm_decode_con[_s->rule.burm_con];
  NODEPTR *_children;
  if(_s->rule.burm_con==0)
    NO_ACTION(con);
  switch(_ern){
  case 16:
{

# line 338 "mybrg.brg"

        //fprintf(stderr, "%s\n",(const char*) burm_string[_ern]);
    
}
  break;
  }
}

# line 77 "mybrg.brg"
int memc_action(struct burm_state *_s, 
# line 77 "mybrg.brg"
int indent)
{
  struct burm_state *_t;
  int _ern=burm_decode_memc[_s->rule.burm_memc];
  NODEPTR *_children;
  if(_s->rule.burm_memc==0)
    NO_ACTION(memc);
  switch(_ern){
  case 9:
{

# line 201 "mybrg.brg"

    int regis, meml;
   fprintf(stderr, "%s\n", (char*)burm_string[_ern]);
    regis = isalreadyinregister((llvm::Value*)_s->node->val);
    meml = getmem((llvm::Value*) (_s->node->val));
    if(regis != -1)//Updating memory from register
    {

        //fprintf(stderr,"\n\t%s\n","loaded memory in register");
        //fprintf(stderr,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(regis),meml);
        fprintf(f,"\tmovq\t%%%s, -%d(%%rbp)\n",getregname(regis),meml);
    }
    //fprintf(stderr, "Alloca %d\t""%s\n",meml, (const char*)burm_string[_ern]);
    return meml;
  
}
  break;
  }
}

# line 78 "mybrg.brg"
void gc_action(struct burm_state *_s, 
# line 78 "mybrg.brg"
int indent)
{
  struct burm_state *_t;
  int _ern=burm_decode_gc[_s->rule.burm_gc];
  NODEPTR *_children;
  if(_s->rule.burm_gc==0)
    NO_ACTION(gc);
  switch(_ern){
  case 17:
{

# line 345 "mybrg.brg"

   fprintf(f,"\tmovq\t%s, %%%s\n",_s->node->val,"rax");
  
}
  break;
  }
}

struct burm_state *burm_alloc_state(NODEPTR u,int op,int arity)
{
  struct burm_state *p, **k;
  p = (struct burm_state *)ALLOC(sizeof *p);
  burm_assert(p, PANIC("1:ALLOC returned NULL in burm_alloc_state\n"));
  p->op = op;
  p->node = u;
  if(arity){
    k=(struct burm_state **)ALLOC(arity*sizeof (struct burm_state *));
    burm_assert(k, PANIC("2:ALLOC returned NULL in burm_alloc_state\n"));
    p->kids=k;
  }else
    p->kids=0;
  p->rule.burm_stmt =
  p->rule.burm_mem =
  p->rule.burm_reg =
  p->rule.burm_con =
  p->rule.burm_memc =
  p->rule.burm_gc =
  p->rule.burm__ =
    0;
  p->cost[1] =
  p->cost[2] =
  p->cost[3] =
  p->cost[4] =
  p->cost[5] =
  p->cost[6] =
  p->cost[7] =
    COST_INFINITY;
  return p;
}
struct burm_state *burm_label1(NODEPTR u) {
  int op, arity, i, immed_matched=0;
  COST c=COST_ZERO;
  struct burm_state *s,**k;
  NODEPTR *children;
  burm_assert(sizeof (int) >= sizeof (void *),PANIC("implementation failure"));
  op=OP_LABEL(u);
  arity=burm_arity[op];
  switch(op){
  case 0:		/* BURP */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
        /*immediate rule: stmt: BURP(_,_,_) */
    if(burm_cost_code(&c,0,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
      s->cost[burm_stmt_NT] = c ;
      s->rule.burm_stmt = 1;
      immed_matched=1;
    }
    if(immed_matched){
      for(i=0;i<arity;i++)k[i]=0;
      return s;
    }
    break;
  case 1:		/* STORE */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* stmt: STORE(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,15,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 15;
      }
    }
    if (   /* stmt: STORE(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,14,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 14;
      }
    }
    if (   /* stmt: STORE(con,mem) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_mem
    ) {
      if(burm_cost_code(&c,13,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 13;
      }
    }
    if (   /* stmt: STORE(reg,mem) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_mem
    ) {
      if(burm_cost_code(&c,12,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 12;
      }
    }
    if (   /* stmt: STORE(mem,mem) */
      k[0]->rule.burm_mem && 
      k[1]->rule.burm_mem
    ) {
      if(burm_cost_code(&c,11,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 11;
      }
    }
    if (   /* stmt: STORE(memc,mem) */
      k[0]->rule.burm_memc && 
      k[1]->rule.burm_mem
    ) {
      if(burm_cost_code(&c,10,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 10;
      }
    }
    break;
  case 2:		/* CNSTINT */
#ifdef LEAF_TRAP
    if(s=LEAF_TRAP(u,op))
      return s;
#endif
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=0;
    {  		/* con: CNSTINT */
      if(burm_cost_code(&c,16,s) && COST_LESS(c,s->cost[burm_con_NT])) {
        s->cost[burm_con_NT] = c ;
        s->rule.burm_con = 1;
      }
    }
    break;
  case 3:		/* COMP */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* stmt: COMP(con,con) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,8,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 9;
      }
    }
    if (   /* stmt: COMP(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,7,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 8;
      }
    }
    if (   /* stmt: COMP(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,6,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 7;
      }
    }
    if (   /* stmt: COMP(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,5,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 6;
      }
    }
    break;
  case 4:		/* ARGS */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* stmt: ARGS(mem) */
      k[0]->rule.burm_mem
    ) {
      if(burm_cost_code(&c,4,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 5;
      }
    }
    if (   /* stmt: ARGS(reg) */
      k[0]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,3,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 4;
      }
    }
    break;
  case 5:		/* GEP */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: GEP(mem,con) */
      k[0]->rule.burm_mem && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,23,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 5;
      }
    }
    if (   /* reg: GEP(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,22,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 4;
      }
    }
    if (   /* reg: GEP(mem,reg) */
      k[0]->rule.burm_mem && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,21,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 3;
      }
    }
    if (   /* reg: GEP(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,20,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 2;
      }
    }
    break;
  case 6:		/* LOAD */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: LOAD(reg) */
      k[0]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,59,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 41;
      }
    }
    if (   /* reg: LOAD(mem) */
      k[0]->rule.burm_mem
    ) {
      if(burm_cost_code(&c,58,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 40;
      }
    }
    if (   /* reg: LOAD(gc) */
      k[0]->rule.burm_gc
    ) {
      if(burm_cost_code(&c,57,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 39;
      }
    }
    break;
  case 7:		/* ALLOCA */
#ifdef LEAF_TRAP
    if(s=LEAF_TRAP(u,op))
      return s;
#endif
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=0;
    {  		/* mem: ALLOCA */
      if(burm_cost_code(&c,18,s) && COST_LESS(c,s->cost[burm_mem_NT])) {
        s->cost[burm_mem_NT] = c ;
        s->rule.burm_mem = 1;
      }
    }
    break;
  case 8:		/* ADD */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: ADD(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,26,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 8;
      }
    }
    if (   /* reg: ADD(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,25,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 7;
      }
    }
    if (   /* reg: ADD(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,24,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 6;
      }
    }
    break;
  case 9:		/* MUL */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: MUL(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,32,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 14;
      }
    }
    if (   /* reg: MUL(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,31,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 13;
      }
    }
    if (   /* reg: MUL(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,30,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 12;
      }
    }
    break;
  case 10:		/* SUB */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: SUB(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,29,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 11;
      }
    }
    if (   /* reg: SUB(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,28,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 10;
      }
    }
    if (   /* reg: SUB(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,27,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 9;
      }
    }
    break;
  case 11:		/* DIV */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: DIV(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,35,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 17;
      }
    }
    if (   /* reg: DIV(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,34,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 16;
      }
    }
    if (   /* reg: DIV(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,33,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 15;
      }
    }
    break;
  case 12:		/* ASR */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: ASR(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,41,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 23;
      }
    }
    if (   /* reg: ASR(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,40,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 22;
      }
    }
    if (   /* reg: ASR(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,39,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 21;
      }
    }
    break;
  case 13:		/* SL */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: SL(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,47,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 29;
      }
    }
    if (   /* reg: SL(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,46,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 28;
      }
    }
    if (   /* reg: SL(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,45,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 27;
      }
    }
    break;
  case 14:		/* CALL */
#ifdef LEAF_TRAP
    if(s=LEAF_TRAP(u,op))
      return s;
#endif
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=0;
    {  		/* reg: CALL */
      if(burm_cost_code(&c,19,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 1;
      }
    }
    break;
  case 15:		/* SDIV */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: SDIV(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,38,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 20;
      }
    }
    if (   /* reg: SDIV(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,37,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 19;
      }
    }
    if (   /* reg: SDIV(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,36,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 18;
      }
    }
    break;
  case 16:		/* GLOBAL */
#ifdef LEAF_TRAP
    if(s=LEAF_TRAP(u,op))
      return s;
#endif
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=0;
    {  		/* gc: GLOBAL */
      if(burm_cost_code(&c,17,s) && COST_LESS(c,s->cost[burm_gc_NT])) {
        s->cost[burm_gc_NT] = c ;
        s->rule.burm_gc = 1;
      }
    }
    break;
  case 17:		/* ARGALLOC */
#ifdef LEAF_TRAP
    if(s=LEAF_TRAP(u,op))
      return s;
#endif
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=0;
    {  		/* memc: ARGALLOC */
      if(burm_cost_code(&c,9,s) && COST_LESS(c,s->cost[burm_memc_NT])) {
        s->cost[burm_memc_NT] = c ;
        s->rule.burm_memc = 1;
      }
    }
    break;
  case 18:		/* RETURN */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* stmt: RETURN(con) */
      k[0]->rule.burm_con
    ) {
      if(burm_cost_code(&c,2,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 3;
      }
    }
    if (   /* stmt: RETURN(reg) */
      k[0]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,1,s) && COST_LESS(c,s->cost[burm_stmt_NT])) {
        s->cost[burm_stmt_NT] = c ;
        s->rule.burm_stmt = 2;
      }
    }
    break;
  case 19:		/* SHR */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: SHR(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,44,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 26;
      }
    }
    if (   /* reg: SHR(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,43,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 25;
      }
    }
    if (   /* reg: SHR(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,42,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 24;
      }
    }
    break;
  case 20:		/* CNSTI */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    break;
  case 21:		/* OR */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: OR(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,53,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 35;
      }
    }
    if (   /* reg: OR(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,52,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 34;
      }
    }
    if (   /* reg: OR(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,51,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 33;
      }
    }
    break;
  case 22:		/* AND */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: AND(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,50,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 32;
      }
    }
    if (   /* reg: AND(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,49,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 31;
      }
    }
    if (   /* reg: AND(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,48,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 30;
      }
    }
    break;
  case 23:		/* XOR */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    if (   /* reg: XOR(reg,con) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_con
    ) {
      if(burm_cost_code(&c,56,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 38;
      }
    }
    if (   /* reg: XOR(con,reg) */
      k[0]->rule.burm_con && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,55,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 37;
      }
    }
    if (   /* reg: XOR(reg,reg) */
      k[0]->rule.burm_reg && 
      k[1]->rule.burm_reg
    ) {
      if(burm_cost_code(&c,54,s) && COST_LESS(c,s->cost[burm_reg_NT])) {
        s->cost[burm_reg_NT] = c ;
        s->rule.burm_reg = 36;
      }
    }
    break;
  case 24:		/* UMUL */
    s=burm_alloc_state(u,op,arity);
    SET_STATE(u,s);
    k=s->kids;
    children=GET_KIDS(u);
    for(i=0;i<arity;i++)
      k[i]=burm_label1(children[i]);
    break;
  default:
    burm_assert(0, PANIC("Bad operator %d in burm_state\n", op));
  }
  return s;
}

struct burm_state *burm_label(NODEPTR p) {
  burm_label1(p);
  return ((struct burm_state *)STATE_LABEL(p))->rule.burm_stmt ? STATE_LABEL(p) : 0;
}

void burm_free(struct burm_state *s)
{
  int i,arity=burm_arity[s->op];
  if(s->kids==0)
    free(s);
  else {
    for(i=0;i<arity;i++)
      burm_free(s->kids[i]);
    free(s->kids);
  }
}
struct burm_state *burm_immed(struct burm_state *s,int n)
{
  NODEPTR *children = GET_KIDS(s->node);
  if(s->kids[n])
    return s->kids[n];
  else
  return s->kids[n]=burm_label1(children[n]);
}
int burm_op_label(NODEPTR p) {
  burm_assert(p, PANIC("NULL tree in burm_op_label\n"));
  return OP_LABEL(p);
}

struct burm_state *burm_state_label(NODEPTR p) {
  burm_assert(p, PANIC("NULL tree in burm_state_label\n"));
  return STATE_LABEL(p);
}

NODEPTR burm_child(NODEPTR p, int index) {
  NODEPTR *kids;
  burm_assert(p, PANIC("NULL tree in burm_child\n"));
  kids=GET_KIDS(p);
  burm_assert((0<=index && index<burm_arity[OP_LABEL(p)]),
    PANIC("Bad index %d in burm_child\n", index));

  return kids[index];
}
NODEPTR *burm_kids(NODEPTR p, int eruleno, NODEPTR kids[]) {
  burm_assert(p, PANIC("NULL tree in burm_kids\n"));
  burm_assert(kids, PANIC("NULL kids in burm_kids\n"));
  switch (eruleno) {
  case 0: /* stmt: BURP(_,_,_) */
    kids[0] = burm_child(p,0);
    kids[1] = burm_child(p,1);
    kids[2] = burm_child(p,2);
    break;
  case 59: /* reg: LOAD(reg) */
  case 58: /* reg: LOAD(mem) */
  case 57: /* reg: LOAD(gc) */
  case 4: /* stmt: ARGS(mem) */
  case 3: /* stmt: ARGS(reg) */
  case 2: /* stmt: RETURN(con) */
  case 1: /* stmt: RETURN(reg) */
    kids[0] = burm_child(p,0);
    break;
  case 56: /* reg: XOR(reg,con) */
  case 55: /* reg: XOR(con,reg) */
  case 54: /* reg: XOR(reg,reg) */
  case 53: /* reg: OR(reg,con) */
  case 52: /* reg: OR(con,reg) */
  case 51: /* reg: OR(reg,reg) */
  case 50: /* reg: AND(reg,con) */
  case 49: /* reg: AND(con,reg) */
  case 48: /* reg: AND(reg,reg) */
  case 47: /* reg: SL(reg,con) */
  case 46: /* reg: SL(con,reg) */
  case 45: /* reg: SL(reg,reg) */
  case 44: /* reg: SHR(reg,con) */
  case 43: /* reg: SHR(con,reg) */
  case 42: /* reg: SHR(reg,reg) */
  case 41: /* reg: ASR(reg,con) */
  case 40: /* reg: ASR(con,reg) */
  case 39: /* reg: ASR(reg,reg) */
  case 38: /* reg: SDIV(reg,con) */
  case 37: /* reg: SDIV(con,reg) */
  case 36: /* reg: SDIV(reg,reg) */
  case 35: /* reg: DIV(reg,con) */
  case 34: /* reg: DIV(con,reg) */
  case 33: /* reg: DIV(reg,reg) */
  case 32: /* reg: MUL(reg,con) */
  case 31: /* reg: MUL(con,reg) */
  case 30: /* reg: MUL(reg,reg) */
  case 29: /* reg: SUB(reg,con) */
  case 28: /* reg: SUB(con,reg) */
  case 27: /* reg: SUB(reg,reg) */
  case 26: /* reg: ADD(reg,con) */
  case 25: /* reg: ADD(con,reg) */
  case 24: /* reg: ADD(reg,reg) */
  case 23: /* reg: GEP(mem,con) */
  case 22: /* reg: GEP(reg,con) */
  case 21: /* reg: GEP(mem,reg) */
  case 20: /* reg: GEP(reg,reg) */
  case 15: /* stmt: STORE(reg,reg) */
  case 14: /* stmt: STORE(con,reg) */
  case 13: /* stmt: STORE(con,mem) */
  case 12: /* stmt: STORE(reg,mem) */
  case 11: /* stmt: STORE(mem,mem) */
  case 10: /* stmt: STORE(memc,mem) */
  case 8: /* stmt: COMP(con,con) */
  case 7: /* stmt: COMP(con,reg) */
  case 6: /* stmt: COMP(reg,con) */
  case 5: /* stmt: COMP(reg,reg) */
    kids[0] = burm_child(p,0);
    kids[1] = burm_child(p,1);
    break;
  case 19: /* reg: CALL */
  case 18: /* mem: ALLOCA */
  case 17: /* gc: GLOBAL */
  case 16: /* con: CNSTINT */
  case 9: /* memc: ARGALLOC */
    break;
  default:
    burm_assert(0, PANIC("Bad external rule number %d in burm_kids\n", eruleno));
  }
  return kids;
}

void dumpCover(NODEPTR p, int goalnt, int indent)
{
  int eruleno = burm_rule(STATE_LABEL(p), goalnt);
  short *nts = burm_nts[eruleno];
  NODEPTR kids[10];
  int i;

  fprintf(stderr, "\t\t");
  for (i = 0; i < indent; i++)
    fprintf(stderr, " ");
  fprintf(stderr, "%s\n", burm_string[eruleno]);
  burm_kids(p, eruleno, kids);
  for (i = 0; nts[i]; i++)
    dumpCover(kids[i], nts[i], indent + 1);
}

# line 1721 "mybrg.brg"


//static int trace;

/* burm_trace - print trace message for matching p; decrement trace */
/*static void burm_trace(NODEPTR p, int eruleno, int cost, int bestcost) {
	if (trace < 0)
		fprintf(stderr, "0x%lx matched %s = %d with cost %d vs. %d\n",(unsigned long int) p,
			burm_string[eruleno], eruleno, cost, bestcost);
	else if (trace > 0 && cost < bestcost) {
		--trace;
		fprintf(stderr, "0x%lx matched %s = %d with cost %d\n",(unsigned long) p,
			burm_string[eruleno], eruleno, cost);
	}
}*/

static void gen(NODEPTR p) {
	if (burm_label(p) == 0)
		fprintf(stderr, "no cover\n");
	else {
		stmt_action(p->x.state,0);
		dumpCover(p, 1, 0);
	}
}

static Tree tree(int op, Tree l, Tree r) {
	Tree t = (Tree) malloc(sizeof *t);

	t->op = op;
	t->kids[0] = l; t->kids[1] = r;
	t->val = 0;
	t->x.state = 0;
	return t;
}


static void openfile()
{
    f = fopen("out.s","w");
}
static void closefile()
{
    fclose(f);
}


/*main(void) {
	Tree t;

	if (getenv("Trace"))
		trace = atoi(getenv("Trace"));
	printf("i = c + 4;\n");
	t = tree(ASGNI,
		tree(ADDRLP, 0, 0),
		tree(ADDI,
			tree(CVCI, tree(INDIRC, tree(ADDRLP, 0, 0), 0), 0),
			(t = tree(CNSTI, 0, 0), t->val = 4, t)
		)
	);
	gen(t);
	return 0;
}*/
